package week3;
import java.util.Scanner;



class  Person{
	private String name;
	private boolean gender;
	private int age;
	private  int id;
	
	private static int count;
	
	static{
		System.out.println("This is static initialization block");
		
	}
	
	
	{
		System.out.println("This is initialization block, id is "+count);
		//id++;
		setId(count);
		count++;
	}
	
	
	public Person(){
		System.out.println("This is constructor");
		id=count;
		
		System.out.println(name+","+age+","+gender+","+--id);
		
	}
	
	public Person(String name,boolean gender,int age){
		this.name=name;
		this.gender=gender;
		this.age=age;
		
		
	}
	
	
	public String toString() {
		return "Person [name=" + name + ", age=" + age + ", gender=" + gender
				+ ", id=" + id++ + "]";
		//id++;
		
	}
	
	
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isGender() {
		return gender;
	}

	public void setGender(boolean gender) {
		this.gender = gender;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}




	
	
}


	

public class pta02 {
public static void main(String[] args) {
		
		
		Scanner sc = new Scanner(System.in);
		while(true){
		int n = Integer.parseInt(sc.nextLine());
		String[] str = new String[n];
		Person[] p1=new Person[n];
		
		
		
		
		for(int i=0;i<n;i++){
			
			str[i]= sc.nextLine();
			
			//Person p2=new Person();
		}
		
		
		
		
		
		
		String[] strDigits=new String[2];
		
		for(int i=n-1;i>=0;i--){
			strDigits=str[i].split(" ");
			
			//String name=strDigits[0];
			int age = Integer.parseInt(strDigits[1]);
			boolean gender=Boolean.valueOf(strDigits[2]);
			
			p1[i]=new Person(strDigits[0],gender,age);
			p1[i].setId(i);
			//System.out.println(p1.toString());
			
		}
		
		for(int i=n-1;i>=0;i--){
			System.out.println(p1[i]);
		}
		
		Person p2=new Person();
		System.out.println(p2.toString());
		
		
		}
		
	}
	

}


